sudo ls > /dev/null
sudo ls > /dev/null
sudo ls > /dev/null


# --------- --------- --------- --------- --------- --------- --------- --------- ---------
# 路径 /home/bit010/WorkingRam/serv_data/www/html/
#
# if u20, config php8-repo
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update 
#
sudo apt install php8.0 php8.0-cli php8.0-common php8.0-imap php8.0-redis php8.0-snmp php8.0-xml php8.0-gd
sudo apt install apache2
sudo service apache2 restart
#
mkdir /home/bit010/WorkingRam/serv_data/www
cp -rfd /var/www /home/bit010/WorkingRam/serv_data/
sudo mv /var/www /var/www.org
sudo ln -s /home/bit010/WorkingRam/serv_data/www /var/www
sudo service apache2 restart
#
mkdir -p /home/bit010/WorkingRam/serv_data/www/html/testing
echo "<?php phpinfo(); ?>" > /home/bit010/WorkingRam/serv_data/www/html/testing/phpinfo.php

# --------- --------- --------- --------- --------- --------- --------- --------- ---------
# 用户权限
mkdir -p /home/bit010/WorkingRam/serv_data/config/apache2
cp /etc/apache2/envvars /home/bit010/WorkingRam/serv_data/config/apache2
sudo mv /etc/apache2/envvars /etc/apache2/envvars.org
sudo ln -s /home/bit010/WorkingRam/serv_data/config/apache2/envvars /etc/apache2/envvars
cat >>/home/bit010/WorkingRam/serv_data/config/apache2/envvars<<EOF
# if(modify) {
export APACHE_RUN_USER=bit010
export APACHE_RUN_GROUP=bit010
# }
EOF
sudo service apache2 restart
# 文件WEB权限
mkdir -p /home/bit010/WorkingRam/serv_data/config/apache2
cp /etc/apache2/apache2.conf /home/bit010/WorkingRam/serv_data/config/apache2
sudo mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.org
sudo ln -s /home/bit010/WorkingRam/serv_data/config/apache2/apache2.conf /etc/apache2/apache2.conf
cat >>/home/bit010/WorkingRam/serv_data/config/apache2/apache2.conf<<EOF
# if(modify) {
<Directory /var/www>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/html/testing>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
# }
EOF
mkdir -p /home/bit010/WorkingRam/serv_data/www/html/testing
sudo service apache2 restart